import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class CheckBoxPage extends StatelessWidget {
  const CheckBoxPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("CheckBoxPage"),
      ),
      body: const Center(child: CheckBoxView()),
    );
  }
}

class CheckBoxView extends StatefulWidget {
  const CheckBoxView({super.key});

  @override
  State<StatefulWidget> createState() {
    return _CheckBoxViewState();
  }
}

class _CheckBoxViewState extends State<CheckBoxView> {
  bool isChecked = true;

  @override
  Widget build(BuildContext context) {
    Color getColor(Set<MaterialState> states) {
      const Set<MaterialState> interactiveStates = <MaterialState>{
        MaterialState.pressed,
        MaterialState.hovered,
        MaterialState.focused,
      };
      if (states.any(interactiveStates.contains)) {
        return Colors.blue;
      }
      return Colors.red;
    }

    return Checkbox(
        checkColor: Colors.white,
        focusColor: Colors.blue,
        value: isChecked,
        onChanged: (bool? value) {
          setState(() {
            isChecked = value!;
          });
        });
  }
}
